package com.chuyi.uilibrary.ui.refresh;

import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * Created by sjx on 2022/7/22
 */
public class HiRefreshLayout extends FrameLayout implements HiRefresh {

    /* 刷新头部的状态 */
    private HiOverView.HiRefreshState hiRefreshState;

    /* 手势监听器 */
    private GestureDetector gestureDetector;

    /* 刷新回调 */
    private HiRefresh.HiRefreshListener hiRefreshListener;

    /* 刷新头部View, 可由用户自定义 */
    protected HiOverView hiOverView;

    /* 用户下拉时最后y的坐标 */
    private int lastY;

    /* 刷新时是否禁止滚动 */
    private boolean disableRefreshScroll;

    public HiRefreshLayout(@NonNull Context context) {
        this(context, null);
    }

    public HiRefreshLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, -1);
    }

    public HiRefreshLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        gestureDetector = new GestureDetector(getContext(), hiGestureDetector);
    }

    HiGestureDetector hiGestureDetector = new HiGestureDetector() {
        @Override
        public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
            return false;
        }
    };

    @Override
    public void setDisableRefreshScroll(boolean disableRefreshScroll) {

    }

    @Override
    public void refreshFinished() {

    }

    @Override
    public void setRefreshListener(HiRefreshListener hiRefreshListener) {

    }

    @Override
    public void setRefreshOverView(HiOverView hiOverView) {

    }


}
